<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../../config.inc.php");
session_start();
$_LangPath = "operate";
include_once(__Language_Path."/selectlanguage_admin.php");
include_once(__Admin_Path."/logincheck_admin_listdata.php");
include_once(__Modules_Path."/ChangeTime.lib.php");
include_once(__Modules_Path."/WagerForm.lib.php");

$arrPower = CheckUsePower("operate");
if($arrPower === false)ErrMsgOutputHTML("Error", "", 1);

$intLID = (int)$_data["LID"];
$intWagerID = (int)$_data["BID"];
$isBlack = trim($_data["isBlack"]);

$strSQL = "select a.ID, a.LottoID, a.Bet_Type, a.MemStake*ROUND(a.MemExchangeRate, 4)*ROUND(a.DirectorRate, 4) as MemStake, a.SubID, a.MainID, a.StockID, b.BetDate, b.BetTime, b.Content as strContent, b.MemAccount from `bet_BetListTmp` a, `bet_BetListContent` b where a.ID = b.ID and LottoID = ".$intLID;
if(strlen($isBlack) > 0){
	if(empty($intWagerID)){
		$strSQL .= " and b.isBlack = ".$isBlack." order by a.ID DESC limit 0, 1";
	}else{
		$strSQL .= " and a.ID > ".$intWagerID." and b.isBlack = ".$isBlack." order by a.ID limit 0, 30";
	}
}else{
	if(empty($intWagerID)){
		$strSQL .= " order by a.ID DESC limit 0, 10";
	}else{
		$strSQL .= " and a.ID > ".$intWagerID." order by a.ID limit 0, 30";
	}
}

$j = 0;
$strTmp = "";
$arrID = array();
$arrUserID = array();
//print date("H:i:s").$strSQL;
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Data Error";
	$GLOBALS["errorhidden"] = "Error: ".PMA_mysql_error($$_Conn)."\nSQL:".$_strSQL."\nLine:".__LINE__."\nPage:".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}
while($Rows = PMA_mysql_fetch_object($RS)){
	$arrUserID[$Rows -> SubID] = $Rows -> SubID;
	$arrUserID[$Rows -> MainID] = $Rows -> MainID;
	$arrUserID[$Rows -> StockID] = $Rows -> StockID;
	$Rows -> strContent = str_replace("<br />", "&nbsp;&nbsp;", $Rows -> strContent);
	if($Rows -> Bet_Type != 15){
		$Rows -> strContent = str_replace("<br>", "&nbsp;&nbsp;", $Rows -> strContent);
	}
	$strTmp .= "Game[".$j."]=new Array('".$Rows -> ID."','".DateForm($Rows -> BetDate, $Rows -> BetTime, "Y-m-d")."','".TimeForm($Rows -> BetDate, $Rows -> BetTime, "H:i:s")."','".number_format($Rows -> MemStake)."','".addslashes($Rows -> MemAccount)."','".addslashes(WagerFormTrans($Rows -> LottoID, $Rows -> Bet_Type, $Rows -> strContent))."','{ID".$Rows -> SubID."}','{ID".$Rows -> MainID."}','{ID".$Rows -> StockID."}');\n";
	if($intWagerID < $Rows -> ID)$intWagerID = $Rows -> ID;
	$j++;
}

if(sizeof($arrUserID) > 0){
	$strSQL = "select ID, Account from `bet_Member` where ID in (".join(",", $arrUserID).")";
	if($RS = @PMA_mysql_query($strSQL, $$_Conn)){
		while($Rows = PMA_mysql_fetch_object($RS)){
			$strTmp = str_replace("{ID".$Rows -> ID."}", $Rows -> Account, $strTmp);
		}
	}
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript">
<!--
if(self == top)location.href="<?php print __AdminReplaceLink;?>";
var Game=new Array();
<?php print $strTmp;?>
parent.BID="<?php print $intWagerID;?>";
parent.ShowBlackList();
//-->
</script>
<?php @mysql_close($$_Conn);?>